﻿using System;

/// <summary>
/// Problem 5 – Angry Bits 
/// The residents of Bitlandia love playing games. They try all sorts of games – outdoor games, team games, 
/// computer games,  but their newest passion is  the  mobile gaming.  All of the  bits in Bitlandia compete in 
/// the game  of Angry Bits. It’s a game played  on a grid  of 16x8 cells, containing  zeros and ones.  All of the 
/// ones  on  the  left  side  (columns  8-15)  denote  a  bird  and  all  of  the  ones  on  the  right  side  (columns  0-7) 
/// denote a pig. The object of the game is to destroy the pigs. To achieve this, the player throws the birds 
/// towards  them.  The  player  wins  if  he  destroys  all  of  the  pigs.  He  also  gets  a  score  according  to  the 
/// destroyed pigs.
/// </summary>
class Angry_Bits
{
	static void Main()
	{
		char[][] matrix = new char[8][];
		for (int i = 0; i < 8; i++)
		{
			ushort number = ushort.Parse(Console.ReadLine());
			matrix[i] = Convert.ToString(number, 2).PadLeft(16, '0').ToCharArray();
		}

		// check where the birds are
		int[] birds = GetBirdColumns(matrix);

		// for columns - check if there is a birth and fire
		int result = 0;
		for (int i = 7; i >= 0; i--)
		{
			for (int j = 0; j < 8; j++)
			{
				if (birds[i] == j)
				{
					matrix[j][i] = '0';
					result += FireBird(ref matrix, j, i);
				}
			}
		}

		// check for pigs left
		bool pigsLeft = false;
		for (int i = 0; i < 8; i++)
		{
			for (int j = 8; j < 16; j++)
			{
				if (matrix[i][j] == '1')
				{
					pigsLeft = true;
					break;
				}
			}
		}

		Console.WriteLine("{0} {1}", result, (pigsLeft ? "No" : "Yes"));
	}

	private static int FireBird(ref char[][] matrix, int x, int y)
	{
		int nx = x;
		int ny = y;

		bool flag = true;
		int count = 0;
		int pigs = 0;

		// fly up-right
		while (flag)
		{
			if (IsValidCoorinates(nx - 1, ny + 1))
			{
				nx--;
				ny++;
				count++;
				pigs = TryToHitPigs(ref matrix, nx, ny);
				if (pigs > 0)
				{ flag = false; }
			}
			else
			{ flag = false; }
		}

		if (pigs == 0)
		{ flag = true; }

		// fly down
		while (flag)
		{
			if (IsValidCoorinates(nx + 1, ny + 1))
			{
				nx++;
				ny++;
				count++;
				pigs = TryToHitPigs(ref matrix, nx, ny);
				if (pigs > 0)
				{ flag = false; }
			}
			else
			{ flag = false; }
		}

		return (count * pigs);
	}

	public static int TryToHitPigs(ref char[][] matrix, int nx, int ny)
	{
		int pigs = 0;

		if (matrix[nx][ny] == '1')
		{
			// center cell
			matrix[nx][ny] = '0';
			pigs++;

			// north
			int xx = nx - 1;
			int yy = ny;
			if (IsValidCoorinates(xx, yy))
			{
				if (matrix[xx][yy] == '1')
				{
					matrix[xx][yy] = '0';
					pigs++;
				}
			}

			// ne
			xx = nx - 1;
			yy = ny + 1;
			if (IsValidCoorinates(xx, yy))
			{
				if (matrix[xx][yy] == '1')
				{
					matrix[xx][yy] = '0';
					pigs++;
				}
			}

			// e
			xx = nx;
			yy = ny + 1;
			if (IsValidCoorinates(xx, yy))
			{
				if (matrix[xx][yy] == '1')
				{
					matrix[xx][yy] = '0';
					pigs++;
				}
			}

			// se
			xx = nx + 1;
			yy = ny + 1;
			if (IsValidCoorinates(xx, yy))
			{
				if (matrix[xx][yy] == '1')
				{
					matrix[xx][yy] = '0';
					pigs++;
				}
			}

			// s
			xx = nx + 1;
			yy = ny;
			if (IsValidCoorinates(xx, yy))
			{
				if (matrix[xx][yy] == '1')
				{
					matrix[xx][yy] = '0';
					pigs++;
				}
			}

			// sw
			xx = nx + 1;
			yy = ny - 1;
			if (IsValidCoorinates(xx, yy))
			{
				if (matrix[xx][yy] == '1')
				{
					matrix[xx][yy] = '0';
					pigs++;
				}
			}

			// w
			xx = nx;
			yy = ny - 1;
			if (IsValidCoorinates(xx, yy))
			{
				if (matrix[xx][yy] == '1')
				{
					matrix[xx][yy] = '0';
					pigs++;
				}
			}

			// nw
			xx = nx - 1;
			yy = ny - 1;
			if (IsValidCoorinates(xx, yy))
			{
				if (matrix[xx][yy] == '1')
				{
					matrix[xx][yy] = '0';
					pigs++;
				}
			}
		}

		return pigs;
	}

	public static bool IsValidCoorinates(int x, int y)
	{
		bool result = true;

		if (x < 0 || y < 0 || x > 7 || y > 15)
		{ result = false; }

		return result;
	}

	private static void PrintMatrix(char[][] matrix)
	{
		Console.WriteLine();
		for (int i = 0; i < 8; i++)
		{
			for (int j = 0; j < 16; j++)
			{
				Console.Write(matrix[i][j]);
				if (j == 7)
				{ Console.Write(" "); }
			}
			Console.WriteLine();
		}
	}

	private static int[] GetBirdColumns(char[][] matrix)
	{
		int[] result = new int[8];

		for (int i = 0; i < 8; i++)
		{
			result[i] = -1;
		}

		for (int i = 0; i < 8; i++)
		{
			for (int j = 0; j < 8; j++)
			{
				if (matrix[i][j] == '1')
				{ result[j] = i; }
			}
		}

		return result;
	}
}